package com.baidumap.administrator.happystudy.utils;

import android.content.Context;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.baidumap.administrator.happystudy.R;
import com.baidumap.administrator.happystudy.model.M_Cart_One;

import java.util.List;

/**
 * 描述：
 * 作者：徐小星 on 2016/11/14 11:08
 * 邮箱：xx@yougudongli.com
 */
public class RadioGroupUtils {

    //    private static String[] mZhiFu = {"支付宝", "微信","余额支付"};
    public static String[] mZhiFu = {"支付宝", "余额支付"};

    /**
     * 初始化支付方式radioButton
     */
    public static void initZhiFuRadioButton(Context context, RadioGroup radioGroup) {
        for (int i = 0; i < mZhiFu.length; i++) {
            RadioButton rb = new RadioButton(context);
            RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1);

            rb.setButtonDrawable(R.drawable.btn_radio_check);
            rb.setPadding(12, 12, 12, 12);
            rb.setId(i);
            if (i == 0) {
                rb.setChecked(true);
            }
            rb.setText(mZhiFu[i]);
            rb.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
            rb.setGravity(Gravity.CENTER_VERTICAL);
            rb.setLayoutParams(params);
            radioGroup.addView(rb);
        }
    }

    /**
     * 初始化配送方式方式radioButton
     */
    public static void initPeiSongFangShi(Context context, RadioGroup rgPeiSongFangShi, List<M_Cart_One.ContentBean.ShippingListBean> contentBeanList) {

        for (int i = 0; i < contentBeanList.size(); i++) {

            RadioButton rb = new RadioButton(context);
            RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
            rb.setId(i);
            rb.setButtonDrawable(R.drawable.btn_radio_check);
            rb.setPadding(12, 12, 12, 12);
//            if (i == 0) {
//                rb.setChecked(true);
//            }
            rb.setText(contentBeanList.get(i).getShipping_name());
            rb.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
            rb.setGravity(Gravity.CENTER_VERTICAL);
            rb.setLayoutParams(params);
            rgPeiSongFangShi.addView(rb);
        }
    }

}
